# import pandas as pd
# import json
# from fuzzywuzzy import process
#
# def load_json_to_dict(file_path):
#     """ 从指定路径加载JSON文件并解析为Python字典 """
#     try:
#         with open(file_path, 'r', encoding='utf-8') as file:
#             data = json.load(file)
#         return data
#     except FileNotFoundError:
#         print(f"错误：文件 {file_path} 未找到。")
#         return None
#     except json.JSONDecodeError:
#         print(f"错误：文件 {file_path} 不是有效的JSON格式。")
#         return None
#     except Exception as e:
#         print(f"未知错误：{e}")
#         return None
#
#
# def fuzzy_search(region_name, threshold=60):
#     """ 根据地区名进行模糊查找对应的天气码 """
#
#     weather_codes=load_json_to_dict("weather_codes.json")
#
#     # 获取所有地区名
#     all_regions = list(weather_codes.keys())
#
#     # 使用 process.extractOne 来获取最佳匹配及其分数
#     best_match, score = process.extractOne(region_name, all_regions)
#
#     # 如果得分高于阈值，则返回匹配的天气码；否则返回 None
#     if score >= threshold:
#         return weather_codes[best_match], best_match, score
#     else:
#         return None, None, score
#
# def get_city_code(city:str):
#     # 使用示例
#     code, match, score = fuzzy_search(city)
#
#     if code:
#         print(f"找到了匹配的地区: {match} (匹配度: {score}%)")
#         print(f"地区 {match} 的天气码是: {code}")
#         return code
#     else:
#         print(f"没有找到与 '{city}' 匹配的地区 (最高匹配度: {score}%)")
#         return 310000